package org.zxy.base.util;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {
    private Boolean success;
    private String  msg;
    private Object  data;

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("操作成功");
        return ajaxResult;
    }

    public static AjaxResult success(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("操作成功");
        ajaxResult.setData(data);
        return ajaxResult;
    }

//    public static AjaxResult success(String msg){
//        AjaxResult ajaxResult = new AjaxResult();
//        ajaxResult.setSuccess(true);
//        ajaxResult.setMsg(msg);
//        return ajaxResult;
//    }

    public static AjaxResult error(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("操作失败"+msg);
        return ajaxResult;
    }

    public static AjaxResult error(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("操作失败");
        ajaxResult.setData(data);
        return ajaxResult;
    }



}
